package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.mvp.model.UserModel
import com.baizan.daka.mvp.model.bean.TaskInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.TaskMgrContract

class TaskMgrPresenter(val mView: TaskMgrContract.View) : BasePresenter(),
    TaskMgrContract.Presenter {

    val userModel: UserModel by lazy { UserModel() }

    override fun loadList(pageNo:Int,usedFlag: Int? ) {
        mView.showLoadingDialog()
        userModel.getPublishTaskList(pageNo, usedFlag)
            .subscribe(object :CommonSubscriber<BasePageResponse<TaskInfoBean>>(compositeDisposable){
                override fun onCallNext(t: BasePageResponse<TaskInfoBean>?) {
                    mView.loadListSuccess(t!!)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }
            })
    }


}

